package com.core.entity.params;

import java.io.UnsupportedEncodingException;

import org.apache.http.entity.StringEntity;

import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.lidroid.xutils.http.RequestParams;

public class JsonParams extends Params {
	private JSONObject reqJson = new JSONObject();

	@Override
	public void build() {

	}

	@Override
	public void put(String key, Object value) {
		try {
			reqJson.put(key, value);
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	@Override
	public RequestParams toValue() throws UnsupportedEncodingException {
		reqParams.setBodyEntity(new StringEntity(reqJson.toJSONString()
				.toString(), "UTF-8"));
		return reqParams;
	}

	@Override
	public String toLog() {
		return reqJson.toString();
	}

}
